import { useCallback, useEffect, useState } from 'react';

function CallBack() {
	const [age, setAge] = useState(16);
	// let age2 = useMemo(() => {
	// 	console.log("11111");
	// 	return age < 18 ? '未成年' : '成年';
	// }, [age <= 18])

	let age2 = useCallback(() => age < 18 ? '未成年' : '成年', [age <= 18])
	console.log('组建跟新')
	return (
		<div>
			年龄: {age} <br />
			阶段: {age2()} <br />
			<button onClick={() => {
				setAge(age + 1);
			}}>新增</button>
		</div>
	)
}
export default CallBack;